<template>
  <div class="rank-container">
    <div class="rank-header">
      <div class="rank-title">{{ title }}</div>
      <div class="rank-value-title">{{ valueTitle }}</div>
    </div>
    <div class="rank-list">
      <div
        v-for="(item, index) in rankData"
        :key="index"
        class="rank-item"
        :class="{ top: index < 3 }"
      >
        <div class="rank-number">{{ index + 1 }}</div>
        <div class="rank-name">{{ item.name }}</div>
        <div class="rank-value">{{ item.value }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Rank',
  props: {
    title: {
      type: String,
      default: '排行榜'
    },
    valueTitle: {
      type: String,
      default: '数值'
    },
    rankData: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style scoped>
.rank-container {
  padding: 20px;
  background: #ffffff;
  box-shadow: 0px 0px 10px 0px rgba(51, 51, 51, 0.15);
  border-radius: 4px;
}

.rank-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.rank-title {
  font-size: 18px;
  font-weight: bold;
  color: #333333;
}

.rank-value-title {
  font-size: 16px;
  color: #333333;
}

.rank-list {
  max-height: 400px;
  overflow-y: auto;
}

.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-number {
  width: 26px;
  height: 26px;
  background: #dddddd;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #666666;
}

.rank-item.top .rank-number {
  background: #ff7911;
  color: #ffffff;
}

.rank-name {
  flex: 1;
  margin-left: 15px;
  color: #333333;
}

.rank-value {
  width: 80px;
  text-align: right;
  color: #333333;
  font-weight: bold;
}
</style>